package com.lagou.service;

import com.lagou.annotation.MyAutowire;
import com.lagou.annotation.MyService;
import com.lagou.annotation.MyTransactional;
import com.lagou.dao.AccountDao;
import com.lagou.utils.TransactionManager;

import java.sql.Connection;

@MyService("accountServiceCglib")
public class AccountServiceCglib {

    @MyAutowire("accountDao")
    private AccountDao accountDao;

    @MyTransactional("transactionManager")
    public void transfer(String from, String to, Double money) {

        accountDao.updateBalanceByUsername(from, money*-1);
//        int a = 1/0;
        accountDao.updateBalanceByUsername(to, money);

    }
}
